package factory.basefactory;

/**
 * @author wcj
 * @Date 2021/6/20 22:11
 * @Version 1.0
 */
public class Client {

 /**
  * 工厂方法模式：目的实现对于对象创建操作的隐藏
  * 优点：实现了对于对象创建操作的隐藏，并且满足了开闭原则
  * 缺点：增加了代码量，每次新增加一个操作我们都需要去新增一个实体类，一个工厂类
  *
  * @param args
  */
 public static void main(String[] args) {
  OperationAddFactory operationAddFactory = new OperationAddFactory();
  Operation operationAdd = operationAddFactory.getOperation();
  System.out.println(operationAdd.operation(5L, 6L));

  OperationSubFactory operationSubFactory = new OperationSubFactory();
  Operation operationSub = operationSubFactory.getOperation();
  System.out.println(operationSub.operation(8L, 5L));

  OperationMultiplyFactory operationMultiplyFactory = new OperationMultiplyFactory();
  Operation operationMul = operationMultiplyFactory.getOperation();
  System.out.println(operationMul.operation(5L, 6L));

  OperationDivideFactory operationDivideFactory = new OperationDivideFactory();
  Operation operationDiv = operationDivideFactory.getOperation();
  System.out.println(operationDiv.operation(6L, 3L));
 }
}
